package com.ruoyi.omp.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.omp.api.RemoteJobService;
import com.ruoyi.omp.api.domain.SysJob;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RemoteJobFactory implements FallbackFactory<RemoteJobService> {

    @Override
    public RemoteJobService create(Throwable throwable) {
        log.error("远程Job服务调用失败:{}", throwable.getMessage());
        return new RemoteJobService() {
            @Override
            public R addJob(SysJob sysJob) {
                return R.fail("添加远程Job服务记录失败:" + throwable.getMessage());
            }

//            @Override
//            public R removeJob(Long[] jobIds) {
//                return R.fail("删除远程Job服务记录失败:" + throwable.getMessage());
//            }

            @Override
            public R editJob(SysJob sysJob) {
                return R.fail("更新远程Job服务记录失败:" + throwable.getMessage());
            }
        };
    }
}
